using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class Test_Log_AnswerInfo
    {
		#region Local Variable
		public enum Field
		{
			Test_Log_No,
			Test_Log_Line,
			Answer_ID,
			Answer_Selected,
			Answer_Order,
			Answer_Text,
			Rank
		}
		private Int32 _Test_Log_No;
		private Int32 _Test_Log_Line;
		private Int64 _Answer_ID;
		private Boolean _Answer_Selected;
		private String _Answer_Order;
		private String _Answer_Text;
		private Int32 _Rank;
		
		public Int32 Test_Log_No{	get{ return _Test_Log_No;} set{_Test_Log_No = value;} }
		public Int32 Test_Log_Line{	get{ return _Test_Log_Line;} set{_Test_Log_Line = value;} }
		public Int64 Answer_ID{	get{ return _Answer_ID;} set{_Answer_ID = value;} }
		public Boolean Answer_Selected{	get{ return _Answer_Selected;} set{_Answer_Selected = value;} }
		public String Answer_Order{	get{ return _Answer_Order;} set{_Answer_Order = value;} }
		public String Answer_Text{	get{ return _Answer_Text;} set{_Answer_Text = value;} }
		public Int32 Rank{	get{ return _Rank;} set{_Rank = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public Test_Log_AnswerInfo()
		{
			_Test_Log_No = 0;
			_Test_Log_Line = 0;
			_Answer_ID = 0;
			_Answer_Selected = false;
			_Answer_Order = "";
			_Answer_Text = "";
			_Rank = 0;
		}
		public Test_Log_AnswerInfo(
		Int32 Test_Log_No,
		Int32 Test_Log_Line,
		Int64 Answer_ID,
		Boolean Answer_Selected,
		String Answer_Order,
		String Answer_Text,
		Int32 Rank
		)
		{
			_Test_Log_No = Test_Log_No;
			_Test_Log_Line = Test_Log_Line;
			_Answer_ID = Answer_ID;
			_Answer_Selected = Answer_Selected;
			_Answer_Order = Answer_Order;
			_Answer_Text = Answer_Text;
			_Rank = Rank;
		}
		public Test_Log_AnswerInfo(DataRow dr)
		{
			if (dr != null)
			{
				_Test_Log_No = dr[Field.Test_Log_No.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.Test_Log_No.ToString()]);
				_Test_Log_Line = dr[Field.Test_Log_Line.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.Test_Log_Line.ToString()]);
				_Answer_ID = dr[Field.Answer_ID.ToString()] == DBNull.Value?0:Convert.ToInt64(dr[Field.Answer_ID.ToString()]);
				_Answer_Selected = dr[Field.Answer_Selected.ToString()] == DBNull.Value?true:Convert.ToBoolean(dr[Field.Answer_Selected.ToString()]);
				_Answer_Order = dr[Field.Answer_Order.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Answer_Order.ToString()]);
				_Answer_Text = dr[Field.Answer_Text.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Answer_Text.ToString()]);
				_Rank = dr[Field.Rank.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.Rank.ToString()]);
			}
		}
		public Test_Log_AnswerInfo(Test_Log_AnswerInfo objEntr)
		{			
			_Test_Log_No = objEntr.Test_Log_No;			
			_Test_Log_Line = objEntr.Test_Log_Line;			
			_Answer_ID = objEntr.Answer_ID;			
			_Answer_Selected = objEntr.Answer_Selected;			
			_Answer_Order = objEntr.Answer_Order;			
			_Answer_Text = objEntr.Answer_Text;			
			_Rank = objEntr.Rank;			
		}
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("Test_Log_Answer");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.Test_Log_No.ToString(), typeof(Int32)),
				new DataColumn(Field.Test_Log_Line.ToString(), typeof(Int32)),
				new DataColumn(Field.Answer_ID.ToString(), typeof(Int64)),
				new DataColumn(Field.Answer_Selected.ToString(), typeof(Boolean)),
				new DataColumn(Field.Answer_Order.ToString(), typeof(String)),
				new DataColumn(Field.Answer_Text.ToString(), typeof(String)),
				new DataColumn(Field.Rank.ToString(), typeof(Int32))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.Test_Log_No.ToString()] = _Test_Log_No;
			row[Field.Test_Log_Line.ToString()] = _Test_Log_Line;
			row[Field.Answer_ID.ToString()] = _Answer_ID;
			row[Field.Answer_Selected.ToString()] = _Answer_Selected;
			row[Field.Answer_Order.ToString()] = _Answer_Order;
			row[Field.Answer_Text.ToString()] = _Answer_Text;
			row[Field.Rank.ToString()] = _Rank;
			return row;
		}
        #endregion InitTable
    }
}
